﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;


public partial class Control_InsertControl : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnRegister_Click(object sender, EventArgs e)
    {
        if(rbmale.Checked == true){
            try
            {
                String kn = "Data Source=WIN7-PC;Initial Catalog=UPDATEDB;User ID=sa;Password=1234567";// chuoi kn
                SqlConnection con = new SqlConnection(kn);
                //con.ConnectionString = ConfigurationManager.ConnectionStrings["Ketnoi"].ConnectionString;
                con.Open();
                SqlCommand com = con.CreateCommand();
                com.CommandType = CommandType.Text;
                com.CommandText = "Insert into Employee ( LoginName, Password, FullName, Sex, Age, Address, Phone, Email, Qualification, Create_Date) Values ( '" + txtName.Text + "', '" + txtpass + "', '" + txtFname + "', 0, '" + int.Parse(txtday.Text) + "', '" + txtdc + "', '" + txtphone + "', '" + txtEmail + "";//cau lenh sql
                int ressut = com.ExecuteNonQuery();
                if (ressut == 1)
                {
                    Response.Redirect("Default2.aspx");
                }
                else
                {
                    Response.Write("Default3.aspx");
                }
                con.Close();
            }
            catch (SqlException ex)
            {
                ex.ToString();
                throw;
            }
        }
         
    }
    
}